package com.csdj.t309springboot.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csdj.t309springboot.common.CacheConstant;
import com.csdj.t309springboot.entity.BlindBox;
import com.csdj.t309springboot.entity.JigsawPuzzlePieces;
import com.csdj.t309springboot.mapper.JigsawPuzzlePiecesMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * <p>
 * 拼图碎片表 服务实现类
 * </p>
 * @author 谭湛宇
 * @since 2022-02-09
 */
@Service
public class JigsawPuzzlePiecesService extends ServiceImpl<JigsawPuzzlePiecesMapper, JigsawPuzzlePieces> implements IJigsawPuzzlePiecesService {
    @Resource
    private JigsawPuzzlePiecesMapper jigsawPuzzlePiecesMapper;

    @Transactional
    public int insert(JigsawPuzzlePieces jigsawPuzzlePieces){
        return jigsawPuzzlePiecesMapper.insert(jigsawPuzzlePieces);
    }

    /**
     * 查询拼图碎片列表
     * @param userId
     * @param jigsawPuzzleId
     * @param blindBoxId
     * @return
     */
    public List<JigsawPuzzlePieces> getJigsawPuzzlePiecesListByUserIdAndJigsawPuzzleIdAndBlindBoxId(int userId,int jigsawPuzzleId,int blindBoxId) {
        QueryWrapper<JigsawPuzzlePieces> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(JigsawPuzzlePieces::getJigsawPuzzleId,jigsawPuzzleId)
                .eq(JigsawPuzzlePieces::getUserId,userId);
//                .eq(JigsawPuzzlePieces::getBlindBoxId,blindBoxId);
        return jigsawPuzzlePiecesMapper.selectList(queryWrapper);
    }
}
